package com.yoshino.prototype.improve;


/**
 * @author yoshino
 **/
public class Client {

    public static void main(String[] args) {
        // 原型模式完成对象创建
        Sheep sheep = new Sheep("tom", 1, "白色");
        sheep.setFriend(new Sheep("jack", 2, "black"));
        try {
            Sheep sheep2 = (Sheep)sheep.clone();
            Sheep sheep3 = (Sheep)sheep.clone();
            Sheep sheep4 = (Sheep)sheep.clone();
            System.out.println(sheep2);
            System.out.println(sheep3);
            System.out.println(sheep4);
            System.out.println(sheep == sheep2);// false
            System.out.println(sheep2 == sheep3);// false
            System.out.println(sheep.getFriend() == sheep2.getFriend());// true
            System.out.println(sheep2.getFriend() == sheep3.getFriend());// true
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }


    }
}
